# Maintainer: Guillaume ALAUX <guillaume@archlinux.org>

pkgname=hunspell-fr
pkgver=6.2
pkgrel=1
pkgdesc='French (modern) hunspell dictionaries'
arch=(any)
url='http://www.dicollecte.org/home.php?prj=fr'
license=('custom:MPLv2')
optdepends=('hunspell: the spell checking libraries and apps')
source=(http://www.dicollecte.org/download/fr/${pkgname/-fr/}-french-dictionaries-v${pkgver}.zip
        LICENSE)
sha256sums=('c98147b99518a5aa51d51db58d6a153377bb9f366ebe8a21a2faa05b6c76308d'
            'fab3dd6bdab226f1c08630b1dd917e11fcb4ec5e1e020e2c16f83a0a13863e85')

package() {
  cd "${srcdir}"
  install -dm755 "${pkgdir}"/usr/share/hunspell
  install -m644 fr-moderne.dic "${pkgdir}"/usr/share/hunspell/fr_FR.dic
  install -m644 fr-moderne.aff "${pkgdir}"/usr/share/hunspell/fr_FR.aff

  pushd "${pkgdir}"/usr/share/hunspell/
  fr_FR_aliases="fr_BE fr_CA fr_CH fr_LU"
  for lang in ${fr_FR_aliases}; do
    ln -s fr_FR.aff ${lang}.aff
    ln -s fr_FR.dic ${lang}.dic
  done

  popd

  # the symlinks
  install -dm755 "${pkgdir}"/usr/share/myspell/dicts
  pushd "${pkgdir}"/usr/share/myspell/dicts
    for file in "${pkgdir}"/usr/share/hunspell/*; do
      ln -sv /usr/share/hunspell/$(basename ${file}) .
    done
  popd

  # docs
  install -Dm644 README_dict_fr.txt "${pkgdir}"/usr/share/doc/${pkgname}/README_dict_fr.txt

  # license
  install -Dm644 LICENSE "${pkgdir}"/usr/share/licenses/${pkgname}/LICENSE
}
